/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 *
 */
import { BaseEvent, EventAdditional, EventBody, EventHead, MetricEventType } from './base-event.js';

export enum InstantEventScope {
  THREAD = 'thread',
  PROCESS = 'process',
  GLOBAL = 'global',
}

export class InstantEventAdditional implements EventAdditional {
  scope?: InstantEventScope;
}

export class InstantEvent extends BaseEvent {
  additional: InstantEventAdditional;

  constructor(id: string, name: string, description: string, pid: number, tid: string) {
    super(new EventHead(id, name, description, MetricEventType.INSTANT), new EventBody(pid, tid));
    this.additional = new InstantEventAdditional();
    this.body.startTime = Number(process.hrtime.bigint());
  }

  setScope(scope: InstantEventScope) {
    this.additional.scope = scope;
  }
}
